﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
using PBOffice.Models;
using PBOffice.BLL;

public partial class ScheduleManager_PersonalSchedule : System.Web.UI.Page
{
    List<Schedule> schList;
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        string strReqTime = "";
        CalendarDay d = ((DayRenderEventArgs)e).Day;     //Day获取表示呈现在   Calendar   控件中的日期的   CalendarDay   
        TableCell c = ((DayRenderEventArgs)e).Cell;       //Cell获取表示呈现在   Calendar   控件中的单元格的   TableCell   对象   
        strReqTime = "<br>" + showTime(d.Date);
        HyperLink link = new HyperLink();
        link.ImageUrl = "~/imges/schedule.png";
        link.NavigateUrl = "MySchedule.aspx?day=" + d.Date.Day.ToString() + "&month=" + d.Date.Month.ToString() + "&year=" + d.Date.Year.ToString();
        link.BorderWidth =0;
        c.Controls.Add(link);
        Label label = new Label();
        label.Text = strReqTime;
        c.Controls.Add(label);
        schList = new ScheduleManager().GetScheduleByDate(d.Date);
        if (schList.Count!=0)
        {
            int id=1;
            foreach (Schedule item in schList)
            {
                 HyperLink btn = new HyperLink();
                 btn.ID = "btn" + id.ToString();
                 btn.CssClass = "schedule";
                string shortTitle=item.Title.Substring(0,3);
                btn.Text = "<br>◎" + item.BeginTime.ToShortTimeString() + shortTitle+"...";
                btn.NavigateUrl = "MySchedule.aspx?id=" + item.ScheduleId.ToString();
                c.Controls.Add(btn);
                id += 1;
            }
        }
       

        

    }


    private static ChineseLunisolarCalendar chineseDate = new ChineseLunisolarCalendar();

    public static string showTime(DateTime mm)
    {
        string[] day = new string[] { "*", "初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十", "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十","廿一"
,"廿一","廿二","廿三","廿四","廿五","廿六","廿七","廿八","廿九","三十" };
        string[] mouth = new string[] { "*", "正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊" };


        int n = chineseDate.GetDayOfMonth(mm);
        int m = chineseDate.GetMonth(mm);
        if (m == 13)
            m = 1;
        return mouth[m] + "月" + day[n];
    }

}